﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MTK_BieuThuc
{
    public class NomialExpr : Expression
    {
        private double a;
        private double n;
        private NomialExpr(double heso, double somu)
        {
            a = heso;
            n = somu;
        }
        public static Expression createObject(double heso, double somu)
        {
            if (heso == 0)
                return ConstExpr.createObject(0);
            if (somu == 0)
                return ConstExpr.createObject(heso);
            return new NomialExpr(heso,somu);

        }
        public override double Evuluate(double x)
        {

            return a*Math.Pow(x,n);
        }
        public override Expression derive()
        {
            return new NomialExpr(a*n,n-1);
        }
        public override string toString(StrategyString ss)
        {
            return a + "X" + "^" + n;
        }
    }
}
